package uniandes.dermatologia;

import uniandes.dermatologia.models.PhysicalExamination.Past;
import uniandes.dermatologia.singleton.DermatologiaUniandesApp;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.support.v4.app.NavUtils;

public class PastActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_past);

		getActionBar().setDisplayHomeAsUpEnabled(false);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.past, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	public void onClickNext(View v) {

		final CheckBox cbAnemia = (CheckBox) findViewById(R.id.cbAnemia);
		final CheckBox cbArthritis = (CheckBox) findViewById(R.id.cbArthritis);
		final CheckBox cbMalnutrition = (CheckBox) findViewById(R.id.cbMalnuitrition);
		final CheckBox cbDiabetes = (CheckBox) findViewById(R.id.cbDiabetes);
		final CheckBox cbEpileptic = (CheckBox) findViewById(R.id.cbEpileptic);
		final CheckBox cbHypertension = (CheckBox) findViewById(R.id.cbHypertension);
		final CheckBox cbHypotension = (CheckBox) findViewById(R.id.cbHypotension);
		final CheckBox cbMyocarditis = (CheckBox) findViewById(R.id.cbMyocarditis);
		final CheckBox cbNeuropathy = (CheckBox) findViewById(R.id.cbNeuropathy);
		final CheckBox cbVIH = (CheckBox) findViewById(R.id.cbVih);
		final CheckBox cbOther = (CheckBox) findViewById(R.id.cbOtherPast);
	
		((DermatologiaUniandesApp) getApplication())
		.getCurrentConsultation().getPhysicalExamination().cleanPast();
		
		if (cbAnemia.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.anemia.toString());
		}
		if (cbArthritis.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.arthritis.toString());

		}
		if (cbMalnutrition.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.malnutrition.toString());

		}
		if (cbDiabetes.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.diabetes.toString());

		}
		if (cbEpileptic.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.epileptic.toString());

		}
		if (cbHypertension.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.hypertension.toString());

		}
		if (cbHypotension.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.hypotension.toString());

		}
		if (cbMyocarditis.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.myocarditis.toString());

		}
		if (cbNeuropathy.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.neuropathy.toString());

		}
		if (cbVIH.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.vih.toString());

		}
		if (cbOther.isChecked()) {
			((DermatologiaUniandesApp) getApplication())
					.getCurrentConsultation().getPhysicalExamination()
					.setPast(Past.other.toString());

		}

		Intent intent = new Intent(this, PhotoActivity.class);
		startActivity(intent);
	}

	public void onClickBack(View v) {
		finish();
	}
}
